#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"1.h"

static int cmp_int(const void * p1, const void *p2);
static int cmp_char(const void * p1, const void *p2);
static int cmp_string(const void * p1, const void *p2);


static void pri_int(const void * p);
static void pri_char(const void * p);
static void pri_string(const void *p);

int main(int argc, char *argv[])
{
	int arr[] = {2,1,3,4,8,7,6,5,22,44,11};
	int len = sizeof(arr) / sizeof(int);

	char str[] = "lkjfasbc";

	
	select_sort(arr, len, sizeof(int), cmp_int);
	show_arr(arr, len, sizeof(int), pri_int);
	printf("\n");
	select_sort(str, strlen(str), sizeof(char), cmp_char);
	show_arr(str, strlen(str), sizeof(char), pri_char);
	printf("\n");

	
	select_sort(argv, argc, sizeof(char *), cmp_string);
	show_arr(argv, argc, sizeof(char *), pri_string);
	return 0;
}

static int cmp_int(const void * p1, const void *p2){
	const int *q1 = (const int *)p1;
	const int *q2 = (const int *)p2;

	return *q1 - *q2;
}


static int cmp_char(const void * p1, const void *p2){
	const char *q1 = (const char *)p1;
	const char *q2 = (const char *)p2;

	return *q1 - *q2;

}
static int cmp_string(const void * p1, const void *p2){
	char **q1 = (char **)p1;
	char **q2 = (char **)p2;
	
	return strcmp(*q1, *q2);
}


static void pri_int(const void * p){
	int *q = (int *)p;
	printf("%d ", *q);
}

static void pri_char(const void * p){
	char *q = (char *)p;
	printf("%c ", *q);
}

static void pri_string(const void *p){
	char **q = (char **)p;
	puts(*q);
}



